//+------------------------------------------------------------------+
//|                                                   HttpClient.mqh |
//|                               Copyright 2016, STW Software Corp. |
//|                                             https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2016, STW Software Corp."
#property link      "https://www.mql5.com"
#property version   "1.00"
#property strict
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
class HttpClient
  {
private:
   static HttpClient *singleton;
   string            _cookies;
public:
                     HttpClient()
     {
      _cookies="";
     };
                    ~HttpClient(){};
   static HttpClient*GetSingleton()
     {
      if(singleton==NULL)
        {
         singleton=new HttpClient();
        }
      return singleton;
     }
   static int RESTful(
               const string      Method,           // HTTP method 
               const string      Url,              // URL  
               const string      DataStr,          // HTTP message body 
               string            &ResultStr,        // an array containing server response data 
               string            &ResultHeaderStr,
               int               TimeOut=5000// timeout 
               )
        {
      char DataChar[];
      char ResultChar[];
      StringToCharArray(DataStr,DataChar,0,StringLen(DataStr));
      int ResponseCode=WebRequest(Method,Url,NULL,NULL,TimeOut,DataChar,ArraySize(DataChar),ResultChar,ResultHeaderStr);
      ResultStr=CharArrayToString(ResultChar);
      return ResponseCode;
     }
  };
  
  HttpClient *HttpClient::singleton=NULL;
//+------------------------------------------------------------------+
